%% Meager (2019) benchmark analysis
% Replicates Figure 8 right panel

% Random seed
seed = 11;

% Initialization
N = 15;
meta_nu_list = 0:0.1:20;
file_path = '../Data/Meager_Data.xlsx';

% Read the "Estimates" and "se" tables for benchmark grouping
estimates1 = readmatrix(file_path, 'Sheet', 'N=15', 'Range', 'B3:D17');
se1 = readmatrix(file_path, 'Sheet', 'N=15', 'Range', 'H3:J17');

% Randomly assign baseline and validation studies
[hat_theta_1, hat_vartheta_1, rep_base_se2_1, rep_val_se2_1] = random_assignment(estimates1, se1, seed);

% Estimate nu from pooled data
tol = 10^-6;
EB_est_nu_1 = MLE_nu(hat_theta_1, rep_base_se2_1, tol);

% Compute empirical coverage frequency for each nu
empirical_cov_list_1 = ecf_over_nu(hat_theta_1, rep_base_se2_1, hat_vartheta_1, rep_val_se2_1, meta_nu_list);

% Generate the ecf plot againt hat-nu
cov_plot_1 = plot_cov_over_nu(empirical_cov_list_1, meta_nu_list, EB_est_nu_1);
saveas(cov_plot_1, '../Results/nu_plot_N_15.png');


